import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';

const path = require('path')

export default defineConfig({
  // 起个别名，在引用资源时，可以用‘@/资源路径’直接访问
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()],
    }),],
  // 配置前端服务地址和端口
  server: {
    host: '0.0.0.0',
    port: 8080,
    // 是否开启 https
    https: false,
    // 设置反向代理，跨域
    proxy: {
      '/api': {
        // 后台地址
        target: 'http://127.0.0.1:3000',//https://admin.cloth.nightowl.top
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      },
      '/image': {
        // 图片资源管理
        target: 'http://127.0.0.1:3000',
        changeOrigin: true,
        //rewrite: path => path.replace(/^\/api/, '')
      },
    },
  },
  // publicDir: "public/"
})
